package com.hzqy.web.ac.epg;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hzqy.service.epg.AcSignServiceBean;
import com.hzqy.web.login.SessionKey;

@Controller
@RequestMapping("/")
public class AcSignAction {
	protected final Logger LOG = LoggerFactory.getLogger(getClass());
	@Resource
	private AcSignServiceBean acSignServiceBean;
	/**
	 * 查今日是否已签到,0否1是
	 */
	@RequestMapping("/acSignToday")
	@ResponseBody
	public Object acSignToday(HttpSession session,String user,String activityId) {
		String userId = (String) session.getAttribute(SessionKey.SESSION_SERVERID);
		Map<String,Integer> map = new HashMap<String,Integer>();
		int result = acSignServiceBean.acSignToday(userId,activityId);
		map.put("result", result);
		return map;
	}
	/**
	 * 插入今天签到
	 */
	@RequestMapping("/acSignInsert")
	@ResponseBody
	public Object acSignInsert(HttpSession session,String user,String activityId) {
		String userId = (String) session.getAttribute(SessionKey.SESSION_SERVERID);
		Map<String,Integer> map = new HashMap<String,Integer>();
		int result = acSignServiceBean.acSignInsert(userId,activityId);
		map.put("result", result);
		return map;
	}
	/**
	 * 查询签到总次数
	 */
	@RequestMapping("/acSignList")
	@ResponseBody
	public Object acSignList(HttpSession session,String user,String activityId) {
		String userId = (String) session.getAttribute(SessionKey.SESSION_SERVERID);
		Map<String,String> map = acSignServiceBean.acSignList(userId,activityId);
		return map;
	}
	
	/**
	 * 查询签到获得抽奖次数
	 */
	public Object lotteryCount(HttpSession session,String activityId) {
		String userId = (String) session.getAttribute(SessionKey.SESSION_SERVERID);
		Map<String,Object> map = acSignServiceBean.lotteryCount(userId,activityId);
		return map;
	}
}
